import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "."

ToolBar {
    property alias title: titleLabel.text
    background: Rectangle {
        color: "#46C76B"
    }

    RowLayout {
        anchors.fill: parent

        FontLoader { id: webFont; source: "qrc:///fonts/Roboto-Medium.ttf" }

        ToolButton {
            id: backButton

            background: Rectangle {
                implicitWidth:  40
                implicitHeight: implicitWidth
                color: backButton.pressed ? "#33333333" : "transparent"

                Image {
                    anchors.fill: parent
                    anchors.margins: 4
                    fillMode: Image.Stretch
                    source: "qrc:/resource/back_arrow.png"
                }
            }

            onClicked: stackView.pop()
        }

        Label {
            id: titleLabel
            anchors.centerIn: parent

            font.family: webFont.name
            font.pixelSize: Units.dp(12)

            elide: Label.ElideRight
            horizontalAlignment: Qt.AlignHCenter
            verticalAlignment: Qt.AlignVCenter
        }
    }
}
